package com.mowh.gof23.structural.patterns.flyweight;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

/**
 * @author mowh1gd
 * @create 2023/10/27 9:34
 */
public class BigChar {
    private char charName;
    private String fontData;

    public BigChar(char charName) {
        this.charName = charName;
        try {
            BufferedReader reader = new BufferedReader(
                    new FileReader(BigChar.class.getClassLoader().getResource("flyweight").getPath() + "/" + "big" + charName + ".txt")
            );
            String line;
            StringBuffer buffer = new StringBuffer();
            while ((line = reader.readLine()) != null) {
                buffer.append(line);
                buffer.append("\n");
            }
            reader.close();
            this.fontData = buffer.toString();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
    public void print() {
        System.out.print(fontData);
    }
}
